package com.weipai.springboot.module.dao.impl;

import com.weipai.springboot.model.PropertyOption;
import com.weipai.springboot.module.dao.PropertyOptionDao;
import com.weipai.springboot.module.mapper.PropertyOptionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.persistence.Id;
import java.util.List;
import java.util.Map;

/**
 * @Author: 曹朋飞
 * @Date: 2018/08/24 14:58
 */
@Repository
public class PropertyOptionDaoImpl implements PropertyOptionDao{

    @Autowired
    private PropertyOptionMapper propertyOptionMapper;

    //保存
    @Override
    public int insert(PropertyOption record) {
        return propertyOptionMapper.insert(record);
    }

    //根据属性id查询所有的属性选项
    @Override
    public List<PropertyOption> getOptionByPropertyId(String id) {
        return propertyOptionMapper.getOptionByPropertyId(id);
    }

    //得到数据库中该属性一共有多少个属性选项
    @Override
    public List<Map<String,Object>> getOptionAmountByPropertyId(String id) {
        return propertyOptionMapper.getOptionAmountByPropertyId(id);
    }

    //删除
    @Override
    public int deleteById(String id) {
        return propertyOptionMapper.deleteByPrimaryKey(id);
    }

    //修改
    @Override
    public int updateOptionName(String optionId, String optionValue,Integer optionSort) {
        return propertyOptionMapper.updateOptionName(optionId, optionValue,optionSort);
    }
}
